import axios from 'axios'
import { message } from 'antd';
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'

// 请求拦截
axios.interceptors.request.use((config) => {
    Nprogress.start()
    let token = sessionStorage.getItem('token')? sessionStorage.getItem('token'): ''
    config.headers.Authorization = token
    return config
})

// 响应拦截
// 白名单 
// 错误处理
axios.interceptors.response.use((data) => {
    Nprogress.done()
    message.success(data.data.msg)
    return data
})

export default axios